package com.leon.learnenginespace.JVM;

import io.micrometer.core.lang.Nullable;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * @description: 配置注入
 * @author: WT
 * @date: 2025/1/10 11:32
 * @Version 1.0
 **/
@Slf4j
public class PropertyResolver {
    Map<String, String> properties = new HashMap<>();

    public PropertyResolver(Properties props) {
        // 存入环境变量:
        this.properties.putAll(System.getenv());
        // 存入Properties:
        Set<String> names = props.stringPropertyNames();
        for (String name : names) {
            this.properties.put(name, props.getProperty(name));
        }
    }
    @Nullable
    public String getProperty(String key) {
        return this.properties.get(key);
    }
}